﻿using System;
using System.Collections.Generic;
using System.IO;

namespace NGE
{
    [Serializable]
    public class NSound : NFile
    {
        public List<byte> Data;

        [NonSerialized]
        protected byte[] data;
        public byte[] DataByte
        {
            get
            {
                if (data == null)
                {
                    data = new byte[Data.Count];
                    int i = 0;
                    foreach (byte b in Data)
                    {
                        data[i] = b;
                        i++;
                    }
                    //Data.Clear();
                }
                return data;
            }
        }
        public MemoryStream DataStream
        {
            get
            {
                return new MemoryStream(DataByte);
            }
        }
        public void GetData(string filename)
        {
            GetData(filename, System.IO.File.ReadAllBytes(filename));
        }
        public void GetData(string filename, byte[] raw)
        {
            Name = filename;
            Data = new List<byte>();
            foreach (byte b in raw)
            {
                Data.Add(b);
            }
        }
    }
}
